package com.mooc.ppjoke.ui.splash

import android.content.Intent
import androidx.lifecycle.Observer
import com.mooc.lib_common.const.BusConst
import com.mooc.lib_common.mvvm.BaseActivity
import com.mooc.ppjoke.BR
import com.mooc.ppjoke.R
import com.mooc.ppjoke.databinding.ActivitySplashBinding
import com.mooc.ppjoke.ui.FrameActivity
import tv.danmaku.ijk.media.player.IjkMediaPlayer

class SplashActivity :BaseActivity<SplashViewModel,ActivitySplashBinding>(){

    override fun initView() {
        v.setVariable(BR.vm,vm)
    }

    override fun bindLayout(): Int {
        return R.layout.activity_splash
    }

    override fun initData() {
        // init player
        IjkMediaPlayer.loadLibrariesOnce(null)
        IjkMediaPlayer.native_profileBegin("libijkplayer.so")
        vm.startData.observe(this, Observer {
            if (it.action.equals(BusConst.STARTPAGE)){
                startActivity(Intent(SplashActivity@this,FrameActivity::class.java))
                finish()
            }
        })
        vm.initData()
    }

}